package com.sztx.pay.center.tool;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;

public class MqMessage {
	private static Logger logger = LoggerFactory.getLogger(MqMessage.class);
	private static HashSet<String> tmpSet = new HashSet<String>();
	private static HashSet<String> tmpSet2 = new HashSet<String>();
	public static void main(String[] args)throws IOException {
		readFile("D:/mq-20170313/mq.gray.0310.log");
		readFile("D:/mq-20170313/mq.gray.0311.log");
		readFile("D:/mq-20170313/mq.gray.0312.log");
		readFile("D:/mq-20170313/mq.gray.0313.log");
		readFile("D:/mq-20170313/mq.pre.0310.log");
		readFile("D:/mq-20170313/mq.pre.0311.log");
		readFile("D:/mq-20170313/mq.pre.0312.log");
		readFile("D:/mq-20170313/mq.pre.0313.log");
		
		
		logger.info("mq消息 数量:"+tmpSet.size()+"  json:"+JSONObject.toJSONString(tmpSet));
		
		checkExsit();
		
	}
	private static void readFile(String path) throws IOException{
		BufferedReader bfs = new BufferedReader(new FileReader(path));
		String readLine = null;
		while ((readLine = bfs.readLine()) != null){
			int index,index2=0;
			index = readLine.indexOf("routingKey:queue.websystem.paycenter|messageContent:");
			index2 = readLine.indexOf("}}");
			if(index > 1 && index2>0){
				String str = readLine.substring(index, index2+2);
				//System.out.println(str);
				tmpSet.add(str);
			}
			
		}
	}
	
	private static void checkExsit() throws IOException{
		BufferedReader bfs = new BufferedReader(new FileReader("D:/mq-20170313/mq.log"));
		String readLine = null;
		while ((readLine = bfs.readLine()) != null){
			tmpSet2.add(readLine);
		}
		System.out.println(tmpSet2.size());
		
	}
	
	
}
